Splines Quick Start


Create a new Spline Object

To create a new spline in the hierarchy, press the plus button and click on Spline > New Spline. image

In the new spline object, you'll find a few properties.

image

Most of these are self explanatory, but here are some explanation to the rest.

Spline Object Properties

  • Use World Space: When checked, the spline will be immovable from its current position.
  • Closed: When checked, will join the first and last points of the spline, creating a closed loop.
  • Anchor Points: Points that connect the curves on the spline. It defaults to two anchor points, and will have 2 identical points in the beginning and end of the points list due to the nature of the catmull-rom spline.

Creating Points

To create new points, be sure the Spline object is selected, and press shift + LMB.
Pressing only shift will preview the next point and line to be placed.

Points will automatically snap its Y axis unto surfaces that have colliders. If there are none, then the point will have a Y of 0.
image

Inserting Points

To insert a point in a spline, control + LMB on a curve and it will add your point in that position. image

Deleting Points

To delete a point, select the point you would like to delete in the scene view and press backspace. image

Spline Animator Component

The Spline Animator script allows keyboard input to manually progress along spline, or a set value to move an object continuously.

image

Spline Animator Properties

  • Spline: The spline the object will follow. If no spline is specified in the inspector, it will automatically find any GameObject titled "Spline."
  • Move Speed: How fast the object will progress.
  • Current Animator: Select between keyboard input or continuous movement.

Spline Animator Events

Spline Animators also have Unity Events to change animation, point of focus, or anything else to create dynamic gameplay.

  • OnStart: Invoked in Start().
  • OnUpdate: Invoked every tick in Update().
  • OnProgressComplete: Invoked when the object has reached the end of its spline.
  • OnRemoved: Invoked when the script is disabled or destroyed.
  • OnCollisionEntered / OnObjectCollisionExited: Invoked when entering or exiting a collider.
  • OnTriggerEntered / OnTriggerExited: Invoked when entering or exiting a trigger.